// pages/detail/detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = options.id;
    console.log(id);
    let url =`http://192.168.0.102:3000/playlist/detail?id=${id}`;
    var reqTask = wx.request({
      url,
      data: {},
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result) => {
        console.log(result.data.playlist.tracks);
        let tracks = result.data.playlist.tracks;
        let playlists = [];
        tracks.forEach(item=>{
          let {id,name,al} = item;
          playlists.push({
            id,
            name,
            picUrl:al.picUrl
          })
        })
        this.setData({
          playlists
        })
        
      }
    });
      

  }
})